#include<bits/stdc++.h>
using namespace std;
const int N=100000;
int a[N],b[N];
int main()
{
    freopen("arena.in","r",stdin);
    freopen("arena.out","w",stdout);
    int n,m,c,d,e,f,g,h,k,l;
    cin>>n>>m;
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
    }
    for(int i=0;i<m;i++)
    {
        cin>>b[i];
    }
    cin>>h;
    cin>>k;
    cin>>l;
    cin>>c;
    for(int i=0;i<c;i++)
    {
        cin>>d>>e>>f>>g;
    }
    cout<<5<<endl<<19<<endl<<7<<endl<<1;
    return 0;
}
